<?php
/**
 * 商品规格验证器
 */

namespace app\common\validate;

class GoodsItemValidate extends CommonBaseValidate
{
    protected $rule = [
            'goods_id|商品' => 'require',
    'name|规格名称' => 'require',
    'image|规格图片' => 'require',
    'price|现价' => 'require',
    'original_price|原价' => 'require',
    'code|编码' => 'require',
    'inventory|库存' => 'require|number',

    ];

    protected $message = [
            'goods_id.required' => '商品不能为空',
    'name.required' => '规格名称不能为空',
    'image.required' => '规格图片不能为空',
    'price.required' => '现价不能为空',
    'original_price.required' => '原价不能为空',
    'code.required' => '编码不能为空',
    'inventory.required' => '库存不能为空',
    'inventory.number' => '库存必须为纯数字',

    ];

    protected $scene = [
        'admin_add'     => ['goods_id', 'name', 'image', 'price', 'original_price', 'code', 'inventory', ],
        'admin_edit'    => ['id', 'goods_id', 'name', 'image', 'price', 'original_price', 'code', 'inventory', ],
        'admin_del'     => ['id', ],
        'admin_disable' => ['id', ],
        'admin_enable'  => ['id', ],
        'api_add'       => ['goods_id', 'name', 'image', 'price', 'original_price', 'code', 'inventory', ],
        'api_info'      => ['id', ],
        'api_edit'      => ['id', 'goods_id', 'name', 'image', 'price', 'original_price', 'code', 'inventory', ],
        'api_del'       => ['id', ],
        'api_disable'   => ['id', ],
        'api_enable'    => ['id', ],
    ];
}
